#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
#include<math.h>

int min(int a, int b) {
	return a > b ? b : a;
}

int check(char* temp) {
	if (temp[0] == 0 && temp[1] == 0 && temp[2] == 0 && temp[3] == 0)
		return 1;
	return 0;
}

void copy(int* a, int* b) {
	a[0] = b[0];
	a[1] = b[1];
	a[2] = b[2];
	a[3] = b[3];

}

int getloc(char a) {
	if (a == 'W')return 0;
	if (a == 'A')return 1;
	if (a == 'S')return 2;
	if (a == 'D')return 3;

}

int main() {
	char input[100002];
	fgets(input, 100002, stdin);
	input[strlen(input) - 1] = '\0';

	int len = strlen(input);

	int count[4] = { 0,0,0,0 };
	for (int i = 0; i < len; i++) {
		switch (input[i]) {
			case 'W':
				count[0]++;
				break;
			case 'A':
				count[1]++;
				break;
			case 'S':
				count[2]++;
				break;
			case 'D':
				count[3]++;
				break;
			default:
				break;
		}
	}
	
	for (int i = 0; i < 4; i++) {
		count[i] -= len / 4;
		if (count[i] <= 0)count[i] = 0;
	}

	if (count[0] == count[1] && count[1] == count[2] && count[2] == count[3]) {
		printf("%d", 0);
		return 0;
	}

	int minlen = pow(10,6);
	int left = 0;
	int right = 0;

	int temp[4];
	copy(temp, count);
	while (right < len) {
		if (temp[getloc(input[right])] > 0)temp[getloc(input[right])]--;
		if (check(temp) == 1)minlen = min(minlen, right - left + 1);
	}



	printf("\n%d %d %d %d", count[0], count[1], count[2], count[3]);



	return 0;

}